package hr.fer.zemris.rznu.model.dao.interfaces;

import hr.fer.zemris.rznu.model.authorization.Role;
import hr.fer.zemris.rznu.model.authorization.Role.RoleType;
import hr.fer.zemris.rznu.model.user.User;

import java.util.Collection;

import javax.persistence.EntityManager;


/**
 * Interface of GeneralDAO.
 * @author Dajan
 */
public interface IGeneralDAO {

	/**
	 * Creates new entity manager (hibernate session).
	 * 
	 * @return Entity Manager.
	 */
	public EntityManager getEntityManager();


	public void createEntityManager();
	
	/**
	 * @see GeneralDAO#save(Object, EntityManager)
	 */
	public void save(Object obj);

	/**
	 * @see GeneralDAO#update(Object, EntityManager)
	 */
	public void update(Object obj);

	/**
	 * @see GeneralDAO#delete(Object, EntityManager)
	 */
	public void delete(Object obj);
	
	/**
	 * Close DAO object.
	 */
	public void close();
	
	/**
	 * Get user by id from database.
	 * 
	 * @param id
	 *            User id.
	 * @param session
	 *            Entity Manager session.
	 * @return User.
	 */
	public User getUserById(Integer id);
	public Role getRoleByName(RoleType roleType);
	public Collection<User> getAdminUsers();
	public Collection<User> getAllUsers();


	User getUserByUserName(String userName);
}
